package com.yonyou.gmmc.service.JDInterface.thread;

import org.apache.log4j.Logger;
import com.yonyou.gmmc.service.JDInterface.service.ProductService;

/** 取鸡蛋线程 */ 
public class GetSimilarSkuThread implements Runnable { 
	private Logger logger = Logger.getLogger(GetSkuStateThread.class);
	private static Integer DUMMY = 0;
    private ProductService productService;
    private BaseThread plate;  

    public GetSimilarSkuThread(BaseThread plate,ProductService productService) {  
        this.plate = plate;   
        this.productService = productService; 
    }  

    public void run() {  
    	logger.info("GetSimilarSkuThread>>>>>>>>>>>>start....."+Thread.currentThread().getName());
    	boolean done = false;
    	while (!done) {  
            //取出队首元素，如果队列为空，则阻塞  
    		Integer pool = plate.getEgg(); 
            if (pool == DUMMY) {  
                //取出来后重新放入，好让其他线程读到它时也很快的结束  
            	plate.putEgg(pool); 
                done = true;  
            } else  {
            	productService.querySimilarSku(pool);
            } 
            logger.warn("GetSimilarSkuThread>>>>>>>>>>>>"+pool+"end....."+Thread.currentThread().getName());
        }
    	logger.warn("GetSimilarSkuThread>>>>>>>>>>>>end....."+Thread.currentThread().getName());
    	logger.info("GetSimilarSkuThread>>>>>>>>>>>>end....."+Thread.currentThread().getName());
    }  
} 
